<template>

</template>

<script>
import * as echarts from 'echarts';
export default {
  name: "Nightingale",
  mounted() {
    this.initCharts()
  },
  methods:{
    initCharts(){
      var chartDom = document.getElementById('china-left-bottom');
      var myChart = echarts.init(chartDom);
      var option;
      $.get(this.$BaseUrl+"/chinaAsiangameInfo/getall",function(resu) {
        const data2=[]
        console.log(resu)
        resu.forEach((value,index)=>{
          data2.push({value:value['countPlayer'],name:value['year']})

        })
        console.log(data2)

      option = {
        title: {
          text: '各届参赛人数占比',
          subtext: '数据来源:百度百科',
          left: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          left: 'center',
          top: 'bottom',
        },
        toolbox: {
          show: true,
          feature: {
            mark: { show: true },
            dataView: { show: true, readOnly: false },
            restore: { show: true },
            saveAsImage: { show: true }
          }
        },
        series: [
          {
            name: '参赛人数',
            type: 'pie',
            radius: [20, 140],
            center: ['60%', '50%'],
            roseType: 'radius',
            itemStyle: {
              borderRadius: 7
            },
            label: {
              show: false
            },
            emphasis: {
              label: {
                show: true
              }
            },
            data:data2
          },
        ]
      };

      option && myChart.setOption(option);
    })
      window.addEventListener("resize",()=>{
        myChart.resize();
      });
    }
  }
}
</script>

<style scoped>

</style>
